import { Router } from 'hyper-express';
import requireUser from '../../../middlewares/auth/requireUser';
import cache from '../../../middlewares/cache';
import rowLevelPermission from '../../../middlewares/auth/rowLevelPermission';
//#region AutoCreateCode
import { uctooDbConnectionController } from '../../../controllers';
const uctoodbConnectionRouter = new Router();
const dbConnectionController = new uctooDbConnectionController();

uctoodbConnectionRouter.post('/add', requireUser, dbConnectionController.add);
uctoodbConnectionRouter.post('/edit', requireUser, rowLevelPermission('uctoo/db_connection'), dbConnectionController.edit);
uctoodbConnectionRouter.post('/del', requireUser, rowLevelPermission('uctoo/db_connection'), dbConnectionController.delete);

//For getting dbConnection with permission control
uctoodbConnectionRouter.get('/:id', requireUser,  rowLevelPermission('uctoo/db_connection'), dbConnectionController.getSingle);
uctoodbConnectionRouter.get('/:limit/:page', requireUser,  rowLevelPermission('uctoo/db_connection'), dbConnectionController.getMany);
uctoodbConnectionRouter.get('/:limit/:page/:skip', requireUser,  rowLevelPermission('uctoo/db_connection'), dbConnectionController.getMany);

//#endregion AutoCreateCode
uctoodbConnectionRouter.post('/asyncDatabaseUrl', requireUser, dbConnectionController.asyncDatabaseUrl);
uctoodbConnectionRouter.post('/initConnection', requireUser, dbConnectionController.initConnection);

export default uctoodbConnectionRouter;
